<template>
	<view>
		加盟店管理 （共{{total}}）
		<uni-table :border="true" class="table-container" sticky>
			<uni-tr>
				<uni-th>id</uni-th>
				<uni-th>企业名称</uni-th>
				<uni-th>企业地址</uni-th>
				<uni-th>联系人</uni-th>
				<uni-th>联系电话</uni-th>
				<uni-th>组织机构代码</uni-th>
				<uni-th>注册时间</uni-th>
				<uni-th>操作</uni-th>
			</uni-tr>
			<uni-tr v-for="(item,index) in memberlist" :key="index">
				<uni-td>{{item.id}}</uni-td>
				<uni-td>{{item.company_name}}</uni-td>
				<uni-td>{{item.address}}</uni-td>
				<uni-td>{{item.legal_person_name}}</uni-td>
				<uni-td>{{item.manager_mobile}}</uni-td>
				<uni-td>{{item.credit_codes}}</uni-td>
				<uni-td>{{item.create_time}}</uni-td>
				<uni-td>
					<button size="mini" type="primary" @click="editme(item)" style="margin-right: 30rpx;">修改</button>
					<button size="mini" type="warn" @click="delme(item)">删除</button>
				</uni-td>
			</uni-tr>
		</uni-table>
		<view style="width: 100%; display: flex;justify-content: center;">
			<pages_button @currentpage="pagechange" :pages="Math.ceil(total/pagesize)" />
		</view>
	</view>
</template>

<script>
	import {
		postrequest
	} from '../../common/apis.js';
	export default {
		name: "corpMemberManage",
		data() {
			return {
				total: 0,
				page: 1,
				pagesize: 20,
				memberlist: ''
			};
		},
		mounted() {
			this.getmemberlist()
			uni.setStorageSync('currentPage', 'corpMemberManage')
		},
		methods: {
			pagechange(e) {
				this.page = e
				this.getmemberlist()
			},
			getmemberlist() {
				let data = {
					username: uni.getStorageSync('username'),
					password: uni.getStorageSync('password'),
					page: this.page,
					pagesize: this.pagesize
				}
				let url = 'https://www.jsyufang.com/yiXun/api/get_erp_corp_shop/index.asp'
				let errmessage = '获取会员列表接口调用失败'
				postrequest(url, data, errmessage, true)
					.then((res) => {
						this.memberlist = res.data.data
						this.total = res.data.total
					})
			},
			formatDateTime(date) {
				function padZero(num) {
					return num < 10 ? '0' + num : num;
				}
				var year = date.getFullYear();
				var month = padZero(date.getMonth() + 1);
				var day = padZero(date.getDate());
				var hours = padZero(date.getHours());
				var minutes = padZero(date.getMinutes());
				var seconds = padZero(date.getSeconds());
				return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
			}

		}
	}
</script>

<style>
	.table-container {
		height: 80vh;
		/* 设置固定高度 */
		overflow-y: auto;
		/* 启用垂直滚动 */
	}
</style>